<template>
  <div class="index">
    <HeadNav />
    <LeftMenu />
    <div class="rightContainer">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
import jwt_decode from 'jwt-decode'
import HeadNav from '../components/HeadNav'
import LeftMenu from "../components/LeftMenu";
export default {
  name: 'index',
  components: {
    HeadNav,
    LeftMenu
  },
  created() {
    const decoded = jwt_decode(localStorage.getItem("eleToken"))
    //存储数据
    this.$store.dispatch('setIsAutnenticated', !this.isEmpty(decoded))
    this.$store.dispatch('setUser', decoded)
  },
  methods: {
    isEmpty(value) {
      return (
        value === undefined ||
        value === null ||
        (typeof value === "object" && Object.keys(value).length === 0) ||
        (typeof value === "string" && value.trim().length === 0)
      );
    }
  }
}
</script>

<style scoped>
.index{
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.rightContainer {
  position: relative;
  top: 0;
  left: 180px;
  width: calc(100% - 180px);
  height: calc(100% - 71px);
  overflow: auto;
}
</style>

